﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<AddressGroupModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%: Resources.All_Contact_Group %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<div class="maincontent">
		<div id="tab">
			<ul>
				<li rel="my">
					<%:Html.ActionLink(Resources.All_Contact, "index", "address", null, null)%></li>
				<li rel="company" class="current">
					<%:Html.ActionLink(Resources.All_Contact_Group, "group", "address", null, null)%></li>
			</ul>
			<%--<div class="clear">
			</div>--%>
		</div>
		<div id="tabcontent">
			<div class="tab" id="my">
				<h2>
					<%:Resources.All_Contact_Group%>
				</h2>
								
			   <div id="datagrid">
				<%using (Ajax.BeginForm("removegroup", "address", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "list", Confirm = Resources.All_DoubleCheck }, FormMethod.Post))
				  { %>
					  <div id="list">
					   <% Html.RenderPartial("contactlist"); %>
					  </div>
				<%  } %>
				</div>
			</div>
		</div>
		
	</div>
	<div class="popupwin">
		<div class="datagrid">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<thead>
					<tr>
						<td width="40%">
							<input type="checkbox" id="selectallcb" onclick="selectall();" /><%:Resources.All_Contact %>
						</td>
						<td>
							<%:Resources.All_Number %>
						</td>
					</tr>
				</thead>
			</table>
			<div class="addresslist">
				<table border="0" cellspacing="0" cellpadding="0" id="contacts">
				</table>
			</div>         
		</div>
	</div>
    <div id="cetd" style="">
        <% using (Html.BeginForm("creategroup", "Address", FormMethod.Post, new { id = "creategroupform" }))
           { %>
                <input name="newgroupname" id="newgroupname" />
				<input type="hidden" name="page" value="<%: Model.page%>" />
                <br />
                <input type="button" onclick="return docreategroup();" class="button" value="<%: Resources.All_Contact_Group_Create %>"/>
                <input type="button" onclick="return closeform();" class="button" value="<%:Resources.All_Cancel %>" />
        <%} %>
    </div>
	<script language="javascript" type="text/javascript">
    function adds() {
            $(".maincontent").mask()
            $("#cetd").show()
            var id = 0;
            //信息
            $('#cetd').dialog({
                title: "<%:Resources.All_Contact_Group_Create%>"
            , iconCls: "icon-template"
                //, border: true
            , width: 300
            , height: 150
//            , buttons: [
//            {
//                text: '<%: Resources.All_Contact_Group_Create %>'
//                , handler: function() {
//                    if($("#newgroupname").val().trim()==""){
//				        alert("<%:Resources.All_Contact_Group_Input%>");
//				        return;
//			        }
//                    else if($("#newgroupname").val().length>40){
//                        alert("<%:Resources.All_Contact_Group_Input_TooLong%>");
//				        return;
//                    }
//			        else{
//				        $("#creategroupform").submit();
//			        }
//                }
//            }
//			,{
//				text: '<%:Resources.All_Cancel %>'
//				, handler: function () {
//					$('#cetd').dialog('close');
//				}
//			}]
            , onClose: function () {
                $(".maincontent").unmask()
            }
            })
            
        }

		function removegroup(){
			var sl = document.getElementById("groups").value;
			var myForm = document.createElement("form");
			myForm.method = "post";
			myForm.action = "<%:Url.Action("RemoveGroup") %>"
			
			var myInput = document.createElement("input");
			myInput.setAttribute("name", "groupid");
			myInput.setAttribute("value", sl);
			myForm.appendChild(myInput);
		  
			document.body.appendChild(myForm);
			myForm.submit();
			document.body.removeChild(myForm);

		}

		 function selectall() {
			var cb = document.getElementById("selectallcb").checked;
			var obj=$("input[name='contactname']");
			$.each(obj, function() {
				this.checked=cb;
			})
		}

		function selected() {
			//alert("23");
			var sl = document.getElementById("groups").value;
			//alert(sl);
			location.href="<%:Url.Action("group") %>"+"?groupid="+sl;
		}

		function docreategroup() {	
			if($("#newgroupname").val().trim()==""){
	            alert("<%:Resources.All_Contact_Group_Input%>");
                return false;
			}
            else if($("#newgroupname").val().length>40){
                alert("<%:Resources.All_Contact_Group_Input_TooLong%>");
			    return false;
            }
			else{
			    $("#creategroupform").submit();
			}			 
		}

        function closeform(){
            $('#cetd').dialog('close');
        }
	   
		$(document).ready(function () {
			var $this = $("#address_CSS")
			$this.addClass("current")
		})
	</script>
  
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
<link rel="stylesheet" type="text/css" href="<%:Url.Content("~/Content/css/themes/default/easyui.css")%>" />
<link rel="stylesheet" type="text/css" href="<%:Url.Content("~/Content/css/themes/icon.css")%>" />
<link href="<%:Url.Content("~/Content/css/address.css")%>" rel="stylesheet" type="text/css" />
<link href="<%:Url.Content("~/Content/css/contactgroup.css")%>" rel="stylesheet" type="text/css" />
<script src="<%:Url.Content("~/Content/js/jquery.bgiframe.js")%>"></script>
<script src="<%:Url.Content("~/Content/js/jquery.easyui.js")%>"></script>
<script src="<%:Url.Content("~/Content/js/jquery.mask.js")%>"></script>

</asp:Content>
